package interviewCode;

import org.junit.Assert;

import java.util.*;

/**
 * @Author: Clarence
 * @Date: 2022/7/21 20:57
 */
public class ListSetMapNullItem {
    public static void main(String[] args) {
        HashMap<String, String> map = new HashMap<>();
        //map只能放一个空的key-value
        map.put(null, null);
        Assert.assertEquals(1, map.size());

        //map.put(null, null);
        //Assert.assertEquals(2,map.size());

        //treeMap的內部存在compareTo方法，key不能是空
        //TreeMap<String, String> treeMap = new TreeMap<>();
        //treeMap.put(null, null);

        ArrayList arrayList = new ArrayList();
        arrayList.add(1);
        arrayList.add(5);
        arrayList.add(6);

        Collections.sort(arrayList);
        System.out.println(arrayList);

        Collections.sort(arrayList, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2-o1;
            //o1在前为升序，o1在后为降序
            }
        });
        System.out.println(arrayList);
    }
}
